<?php

/**
 * This is the model class for table "tabelle_projekte".
 *
 * The followings are the available columns in table 'tabelle_projekte':
 * @property integer $projekt_id
 * @property string $projekt_nr
 * @property string $projekt_name
 * @property string $projekt_name_kurz
 * @property string $fkz
 * @property string $projekt_start
 * @property string $projekt_ende
 * @property integer $projekt_dauer
 * @property string $bew_jahr
 * @property string $antrags_jahr
 * @property integer $status_id
 * @property integer $stufe_id
 * @property integer $kategorie_id
 * @property integer $mittelgeber_id
 * @property integer $programm_id
 * @property integer $unterprogramm_id
 * @property integer $teilnehmer_status
 * @property string $notiz
 * @property string $buro_nr_1
 * @property string $buro_nr_2
 * @property string $buro_nr_3
 * @property integer $projekt_summe
 * @property integer $fsu_summe
 * @property integer $projekt_summe_fsu
 * @property integer $fordersummer_fsu
 * @property integer $overhead
 * @property integer $korrdinator_summe
 * @property string $internet
 * @property string $intranet
 * @property string $formc1
 * @property string $formc2
 * @property string $formc3
 * @property string $formc4
 * @property string $patent
 * @property integer $betreuer_kategorie
 * @property string $kostenstelle
 * @property string $projekttr
 * @property string $eingabedatum
 * @property string $eingabeperson
 * @property string $vertrag
 * @property string $mittelgeber_neu
 *
 * The followings are the available model relations:
 * @property MittelgeberKategorie $kategorie
 */
class Projekte extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Projekte the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tabelle_projekte';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			
			array('projekt_dauer, status_id, stufe_id, programm_id, unterprogramm_id, teilnehmer_status, projekt_summe, fsu_summe, projekt_summe_fsu, fordersummer_fsu, overhead, korrdinator_summe, betreuer_kategorie', 'numerical', 'integerOnly'=>true),
			array('projekt_nr, fkz, buro_nr_1, buro_nr_2, buro_nr_3, kostenstelle, eingabeperson, vertrag', 'length', 'max'=>50),
			array('projekt_name', 'length', 'max'=>250),
			array('projekt_name_kurz', 'length', 'max'=>200),
			array('bew_jahr, antrags_jahr, patent', 'length', 'max'=>4),
			array('projekttr', 'length', 'max'=>150),
			array('mittelgeber_id', 'length', 'max'=>200),
			array('projekt_start, projekt_ende, notiz, internet, intranet, formc1, formc2, formc3, formc4, eingabedatum', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('projekt_id, projekt_nr, projekt_name, projekt_name_kurz, fkz, projekt_start, projekt_ende, projekt_dauer, bew_jahr, antrags_jahr, status_id, stufe_id, kategorie_id, mittelgeber_id, programm_id, unterprogramm_id, teilnehmer_status, notiz, buro_nr_1, buro_nr_2, buro_nr_3, projekt_summe, fsu_summe, projekt_summe_fsu, fordersummer_fsu, overhead, korrdinator_summe, internet, intranet, formc1, formc2, formc3, formc4, patent, betreuer_kategorie, kostenstelle, projekttr, eingabedatum, eingabeperson, vertrag', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'kategorie' => array(self::BELONGS_TO, 'MittelgeberKategorie', 'kategorie_id'),
			'mittelgeber' => array(self::BELONGS_TO, 'Mittelgeber', 'mittelgeber_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'projekt_id' => 'Projekt',
			'projekt_nr' => 'Projekt Nr',
			'projekt_name' => 'Projekt Name',
			'projekt_name_kurz' => 'Projekt Name Kurz',
			'fkz' => 'Fkz',
			'projekt_start' => 'Projekt Start',
			'projekt_ende' => 'Projekt Ende',
			'projekt_dauer' => 'Projekt Dauer',
			'bew_jahr' => 'Bew Jahr',
			'antrags_jahr' => 'Antrags Jahr',
			'status_id' => 'Status',
			'stufe_id' => 'Stufe',
			'kategorie_id' => 'Kategorie',
			'mittelgeber_id' => 'Mittelgeber',
			'programm_id' => 'Programm',
			'unterprogramm_id' => 'Unterprogramm',
			'teilnehmer_status' => 'Teilnehmer Status',
			'notiz' => 'Notiz',
			'buro_nr_1' => 'Buro Nr 1',
			'buro_nr_2' => 'Buro Nr 2',
			'buro_nr_3' => 'Buro Nr 3',
			'projekt_summe' => 'Projekt Summe',
			'fsu_summe' => 'Fsu Summe',
			'projekt_summe_fsu' => 'Projekt Summe Fsu',
			'fordersummer_fsu' => 'Fordersummer Fsu',
			'overhead' => 'Overhead',
			'korrdinator_summe' => 'Korrdinator Summe',
			'internet' => 'Internet',
			'intranet' => 'Intranet',
			'formc1' => 'Formc1',
			'formc2' => 'Formc2',
			'formc3' => 'Formc3',
			'formc4' => 'Formc4',
			'patent' => 'Patent',
			'betreuer_kategorie' => 'Betreuer Kategorie',
			'kostenstelle' => 'Kostenstelle',
			'projekttr' => 'Projekttr',
			'eingabedatum' => 'Eingabedatum',
			'eingabeperson' => 'Eingabeperson',
			'vertrag' => 'Vertrag',
			
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;
		$criteria->with = array( 'kategorie');
		$criteria->compare('projekt_id',$this->projekt_id);
		$criteria->compare('projekt_nr',$this->projekt_nr,true);
		$criteria->compare('projekt_name',$this->projekt_name,true);
		$criteria->compare('projekt_name_kurz',$this->projekt_name_kurz,true);
		$criteria->compare('fkz',$this->fkz,true);
		$criteria->compare('projekt_start',$this->projekt_start,true);
		$criteria->compare('projekt_ende',$this->projekt_ende,true);
		$criteria->compare('projekt_dauer',$this->projekt_dauer);
		$criteria->compare('bew_jahr',$this->bew_jahr,true);
		$criteria->compare('antrags_jahr',$this->antrags_jahr,true);
		$criteria->compare('status_id',$this->status_id);
		$criteria->compare('stufe_id',$this->stufe_id);
		$criteria->compare('kategorie.kategorie_name',$this->kategorie_id);
		$criteria->compare('mittelgeber_id',$this->mittelgeber_id);
		$criteria->compare('programm_id',$this->programm_id);
		$criteria->compare('unterprogramm_id',$this->unterprogramm_id);
		$criteria->compare('teilnehmer_status',$this->teilnehmer_status);
		$criteria->compare('notiz',$this->notiz,true);
		$criteria->compare('buro_nr_1',$this->buro_nr_1,true);
		$criteria->compare('buro_nr_2',$this->buro_nr_2,true);
		$criteria->compare('buro_nr_3',$this->buro_nr_3,true);
		$criteria->compare('projekt_summe',$this->projekt_summe);
		$criteria->compare('fsu_summe',$this->fsu_summe);
		$criteria->compare('projekt_summe_fsu',$this->projekt_summe_fsu);
		$criteria->compare('fordersummer_fsu',$this->fordersummer_fsu);
		$criteria->compare('overhead',$this->overhead);
		$criteria->compare('korrdinator_summe',$this->korrdinator_summe);
		$criteria->compare('internet',$this->internet,true);
		$criteria->compare('intranet',$this->intranet,true);
		$criteria->compare('formc1',$this->formc1,true);
		$criteria->compare('formc2',$this->formc2,true);
		$criteria->compare('formc3',$this->formc3,true);
		$criteria->compare('formc4',$this->formc4,true);
		$criteria->compare('patent',$this->patent,true);
		$criteria->compare('betreuer_kategorie',$this->betreuer_kategorie);
		$criteria->compare('kostenstelle',$this->kostenstelle,true);
		$criteria->compare('projekttr',$this->projekttr,true);
		$criteria->compare('eingabedatum',$this->eingabedatum,true);
		$criteria->compare('eingabeperson',$this->eingabeperson,true);
		$criteria->compare('vertrag',$this->vertrag,true);
		

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}